<?php
require_once '../sub/init.php';
header("Cache-control: private");
require_once 'chkUadm.php';
if(!ADMQX('lovetest')){exit(noauth('暂无【情感测试】权限'));}
$qid=intval($qid);
$row = $db->ROW(__TBL_LOVETEST_BANK__,"subjsonstr","id=".$qid,"num");
if ($row){
	$answerS = dataIO($row[0],'out');
	$answerS = json_decode($answerS);
}else{
	exit('<br><br>查询对应的题库不存在或已被删除');
}
if($submitok=='ajax_del'){
	$tmeplist = $list;
	if(empty($tmeplist))json_exit(array('flag'=>0,'msg'=>'请选择您要删除的信息'));
	if(!is_array($tmeplist))exit(JSON_ERROR);
	if(count($tmeplist)>=1){
		foreach($tmeplist as $value){$id=intval($value);
			if (!ifint($id))json_exit(array('flag'=>0,'msg'=>'记录不存在'));
			$row = $db->ROW(__TBL_LOVETEST_ANSWER__,"uid","id=".$id);
			if ($row){$uid= $row[0];}else{json_exit(array('flag'=>0,'msg'=>'记录不存在'));}
			$db->query("DELETE FROM ".__TBL_LOVETEST_ANSWER__." WHERE qid=".$qid." AND id=".$id);
		}
	}
	json_exit(array('flag'=>1,'msg'=>'删除成功'));
}
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src="<?php echo HOST;?>/res/www_zeai_cn.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<link href="css/main.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css">
<style>
.listdatabox{padding:10px 0}
.listdatabox li{display:inline-block;padding:1px 5px;border:#ddd 1px solid;margin:3px;border-radius:3px;color:#888}
img.photo_s40{border-radius:2px;display:inline-block;;vertical-align:middle}
i.add{display:inline-block;color:#fff;border-radius:50px;width:16px;height:16px;text-align:center;font-size:12px;margin-right:2px}
i.wxlv{color:#31C93C;margin-right:2px}
.timestyle{color:#f00}
</style>
</head>
<body class="body">
<?php 
$SQL = "";
$Skey = trimhtml($Skey);
if (ifmob($Skey)){
	$SQL = " AND (U.mob=$Skey) ";
}elseif(ifint($Skey)){
	$SQL = " AND (a.uid=$Skey) ";
}elseif(!empty($Skey)){
	$SQL = " AND ( U.nickname LIKE '%".$Skey."%' OR U.truename LIKE '%".$Skey."%' )";
}
$rt = $db->query("SELECT a.id,a.uid,a.answer,a.score,a.addtime,U.nickname,U.sex,U.grade,U.photo_s FROM ".__TBL_LOVETEST_ANSWER__." a,".__TBL_USER__." U WHERE a.qid=".$qid." AND a.uid=U.id ".$SQL." ORDER BY a.id DESC");
$total = $db->num_rows($rt);
?>
<div class="navbox">
<a href="lovetest_u.php?qid=<?php echo $qid;?>" <?php echo (empty($s))?' class="ed"':'';?>>测试用户管理<?php echo '<b>'.$total.'</b>';?></a>
<div class="Rsobox"></div>
<div class="clear"></div></div>
<div class="fixedblank"></div>
<?php
	if ($total <= 0 ) {
		echo "<div class='nodataico Mtop50'><i></i>暂无信息";
		echo "</div>";
	} else {
		$page_skin = 1;$pagesize=20;require_once ZEAI.'sub/page.php';
?>
<table class="table0 W95_ Mtop10">
<tr>
<td align="left" class="S14">
  <form name="www.yzlove.com.v6.0..QQ7144100" method="get" action="<?php echo SELF; ?>">
    <input name="Skey" type="text" id="Skey" maxlength="25" class="input size2 W200" placeholder="按UID/姓名/手机/昵称查询">
    <input type="hidden" name="qid" value="<?php echo $qid;?>" />
    <input type="submit" value="搜索" class="btn size2" />
  </form>   
</td>
<td align="left" class="S14"></td>
<td align="right" class="S14"></td>
</tr>
</table>
<div class="clear"></div>
<form id="www_zeai_cn_FORM">
    <table class="tablelist" style="width:98%;margin:10px auto 50px auto">
    <tr>
    <th width="20"><input type="checkbox" id="checkboxall1" class="checkskin checkboxall"><label for="checkboxall1" class="checkskin-label"><i class="i1"></i></label></th>
    <th colspan="2" align="left">　UID/昵称</th>
    <th align="left">测试结果</th>
    <th width="70" align="center">测试时间</th>
    <th width="40" align="center">删除</th>
    </tr>
    <?php
    for($i=1;$i<=$pagesize;$i++) {
        $rows = $db->fetch_array($rt,'name');
        if(!$rows) break;
        $id       = $rows['id'];
        $uid      = $rows['uid'];
		$score    = $rows['score'];
		$answer = dataIO($rows['answer'],'out');
        $addtime = YmdHis($rows['addtime']);
        $photo_s  = $rows['photo_s'];
        $sex      = $rows['sex'];
        $grade    = $rows['grade'];
		$nickname = trimhtml(dataIO($rows['nickname'],'out'));
		//
		$photo_s_url = (!empty($photo_s))?$_ZEAI['up2'].'/'.$photo_s:HOST.'/res/photo_s'.$sex.'.png';
    ?>
	<tr id="tr<?php echo $id;?>">
    <td width="20" height="30" align="left"><input type="checkbox" name="list[]" value="<?php echo $id; ?>" id="id<?php echo $id; ?>" uid="<?php echo $uid; ?>" class="checkskin"><label for="id<?php echo $id; ?>" class="checkskin-label"><i class="i1"></i></label></td>
    <td width="60" height="30" align="center">
    <a href="<?php echo Href('crm_u',$uid);?>"><img class="photo_s" src="<?php echo $photo_s_url; ?>"></a></td>
    <td width="150" height="30" align="left"><?php echo uicon($sex.$grade) ?><?php echo '<font class="picmiddle">'.$uid.'</font></br>　 '.$nickname;?></a></td>
    <td height="30" align="left" class="lineH150 padding10">
    <font style="color:#ff0000"><?php echo $score;?>分</font><br>
    <?php 
	$anums = count($answerS);
	if (is_array($answerS) && $anums>0){
		$tmp_outstr = '';
		$px = 0;
		for($j=0;$j<$anums;$j++) {
			$score1    = intval($answerS[$j]->s1);
			$score2 = intval($answerS[$j]->s2);
			if($score>=$score1 && $score<=$score2){$tmp_outstr = $answerS[$j]->v;}
		}
	}
	echo str_replace("n","<br>",$tmp_outstr);
	?>
    </td>
    <td width="70" align="center" class="S12 C999"><?php echo $addtime;?></td>
    <td width="40" align="center"><a title="删除" qid="<?php echo $qid; ?>" clsid="<?php echo $id; ?>" class="delico"></a></td>
    </tr>
    <?php } ?>
    <div class="listbottombox">
        <input type="checkbox" id="checkboxall2" class="checkskin checkboxall"><label for="checkboxall2" class="checkskin-label"><i class="i1"></i></label>　
        <button type="button" id="btndellist" value="" class="btn HEI size2 disabled action">删除</button>
        <input type="hidden" name="submitok" id="submitok" value="" />
        <?php if ($total > $pagesize)echo '<div class="pagebox FR">'.$pagelist.'</div>'; ?></div>
    </div>
</table>
</form>
<script>
var bg = '<?php echo $_Style['list_bg']; ?>',overbg   = '<?php echo $_Style['list_overbg']; ?>',selectbg = '<?php echo $_Style['list_selectbg']; ?>';
var qid='<?php echo $qid;?>';
zeai.listEach('.delico',function(obj){
	obj.onclick = function(){
		var id = parseInt(obj.getAttribute("clsid")),
		qid = parseInt(obj.getAttribute("qid"));
		zeai.confirm('确定真的要删除么（不可恢复）？',function(){
			zeai.ajax({url:'lovetest_u'+zeai.ajxext+'submitok=ajax_del&qid='+qid+'&list[]='+id},function(e){var rs=zeai.jsoneval(e);
				zeai.msg(0);zeai.msg(rs.msg);
				if(rs.flag==1){setTimeout(function(){location.reload(true);},1000);}
			});
		});
	}
});
o('btndellist').onclick = function() {
	allList({
		btnobj:this,
		url:'lovetest_u'+zeai.ajxext+'submitok=ajax_del&qid='+qid,
		title:'批量删除',
		msg:'正在删除中...',
		ifjson:true,
		ifconfirm:true
	});	
}
</script>
<script src="js/zeai_tablelist.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<?php }?>
<br><br><br><br>
</body>
</html>
